package fr.univ.lille1.android.network;

import java.util.Calendar;
import java.util.UUID;

import fr.univ.lille1.android.domain.SessionKey;
import fr.univ.lille1.android.domain.User;
import retrofit.RestAdapter;

public class UserMockManager {
	public UserMockManager(final RestAdapter restAdapter) {
		// Do nothing with this rest adapter.
	}

	/**
	 * Mock to sign in a user.
	 * 
	 * @param name
	 *            Name of the user.
	 * @param email
	 *            E-mail of the user.
	 * @param password
	 *            Password of the user.
	 * @return User logged.
	 */
	public SessionKey signIn(final String name, final String email,
			final String password) {
		// Creating user logged.
		final User loggedUser = new User();
		loggedUser.setId(1);
		loggedUser.setMail(email);
		loggedUser.setName(name);
		loggedUser.setPassword(password);
		// Generate timestamp + 7 day.
		final Calendar cal = Calendar.getInstance();
		cal.add(Calendar.DATE, 7);
		// Creating session key.
		final SessionKey sessionKey = new SessionKey();
		sessionKey.setUser(loggedUser);
		sessionKey.setSessionKey(UUID.randomUUID().toString());
		sessionKey.setGenerateTime(cal.getTimeInMillis());
		return sessionKey;
	}

	/**
	 * Mock to log in a user.
	 * 
	 * @param email
	 *            E-mail of the user.
	 * @param password
	 *            Password of the user.
	 * @return User logged.
	 */
	public SessionKey login(final String email, final String password) {
		return signIn("androwiiid", email, password);
	}

	/**
	 * Mock to log out a user.
	 * 
	 * @param email
	 *            E-mail of the user.
	 */
	public void logout(final String email) {
		// Nothing to do here.
	}
}
